package com.jackyzgy.test.socket.copy2;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.ObjectInputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

public class Client {
	
	public static void main(String[] args) throws UnknownHostException, IOException, ClassNotFoundException {
		Socket client = new Socket("localhost", 5000);
//		ObjectInputStream objectInputStream = new ObjectInputStream(client.getInputStream());
//		List list = (List) objectInputStream.readObject();
//		for (int i = 0; i < list.size(); i++) {
//			System.out.println(list.get(i));
//		}
		
		OutputStream os = client.getOutputStream();
		PrintStream printStream = new PrintStream(os);
		InputStream is = client.getInputStream();
		BufferedReader br = new BufferedReader(new InputStreamReader(is));
		
		while (true) {
//			printStream.println("113");
//			printStream.flush();
//			printStream.close();
//			try {
//				Thread.sleep(1000);
//			} catch (InterruptedException e) {
//				e.printStackTrace();
//			}
//		    int i = is.read();
			String i = br.readLine();
		    System.out.println(i);
		}
//	    
//	    JSONArray array = JSONArray.fromObject(requestStr);
//		for (int i = 0; i < array.size(); i++) {
//			JSONObject jsonObject = JSONObject.fromObject(array.get(i));
//			System.out.println(jsonObject.getString("content"));
//		}
	    
//		objectInputStream.close();
//		reader.close();
//		client.close();
	}

}
